<?php 
/**
 * this class provides functions for reading from files
 */

class FileReader{
	private $dir;
	private $file;
	private $action;
	
	/**
	 * sets the variables
	 * @param 		string		 $dir
	 * @param 		string		 $file
	 */
	public function __construct($dir, $file, $action) {
		$this->file = $dir . '/' . $file;
		$this->dir = $dir;
		$this->action = $action;
	}
	
	
	/**
	 * reads the file and returns content
	 */
	public function readFile(){
		$binaryContent = '';
		if (file_exists($this->file)){
			$fp = fopen ($this->file, $this->action);
			flock($fp, 2);
			while (!feof($fp))
				$binaryContent .= fread($fp, 100);
			flock($fp, 3);
			fclose($fp);
		}
		return $binaryContent;
	}
}
	
?>